/*
 * @Author: 赵成功a 3063126760@qq.com
 * @Date: 2024-12-25 22:25:49
 * @LastEditors: 赵成功a 3063126760@qq.com
 * @LastEditTime: 2024-12-26 23:05:28
 * @FilePath: /12-25/Server.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include"Init.hpp"
#include"Log.hpp"

int main()
{
    Log log;
    Init init;
    log.Enable(Classfile);
    int fd=open(FIFE_PIPE,O_RDONLY);
    if(fd<0){
        perror("open");
        exit(OPEN_ERR);
    }
    log(Info, "server open file done, error string: %s, error code: %d", strerror(errno), errno);
    log(Warning, "server open file done, error string: %s, error code: %d", strerror(errno), errno);
    log(Fatal, "server open file done, error string: %s, error code: %d", strerror(errno), errno);
    log(Debug, "server open file done, error string: %s, error code: %d", strerror(errno), errno);
    while(true)
    {
        char buffer[SIZE];
        size_t n=read(fd,buffer,sizeof(buffer));
        if(n<0){
            perror("read");
            exit(5);
        }
        if(n==0)break;
        buffer[n]='\0';//这里用n，因为用strlen不准确
        cout<<"Server receive@:"<<buffer<<endl;
    }
    int n=close(fd);
    if(n<0){
        perror("close");
        exit(CLOSE_ERR);
    }
    return 0;
}

